package pw.canyingisme.plugin.occupation;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import pw.canyingisme.plugin.api.Bukkit;
import pw.canyingisme.plugin.myConsole.Consoleself;

public class OccupationCommand {

    public static boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
        if(label.equalsIgnoreCase("occupation")){
            if (Bukkit.isPlayerSender(sender)){
                if (args.length==0){
                    OccupationLanguage.sendHelp(sender);
                    return true;
                }
                if(args.length==1){
                    if (args[0].equalsIgnoreCase("help")){
                        OccupationLanguage.sendHelp(sender);
                        return true;
                    }
                    if (args[0].equalsIgnoreCase("me")){
                        OccupationLanguage.sendSelfOccupation(sender);
                        return true;
                    }
                }
                if(args.length==2){
                    if(args[0].equalsIgnoreCase("choice")){
                        if(args[1].equalsIgnoreCase("list")){
                            OccupationLanguage.sendJobList(sender);
                            return true;
                        }else {
                            OccupationManager.choiceOccupation(sender,args[1]);
                            return true;
                        }
                    }
                }
                OccupationLanguage.sendHelp(sender);
            }else {
                if (args.length==1){
                    if (args[0].equalsIgnoreCase("help")){
                        OccupationLanguage.sendHelp(sender);
                        return true;
                    }
                }
                Consoleself.outPut("ShadowOccupation","此命令禁止Console用户使用 原因:你想给控制台安排个职业?");
            }
            return true;
        }else if(label.equalsIgnoreCase("occupation-admin")){
            if(args.length==0){
                OccupationLanguage.sendAdminHelp(sender);
                return true;
            }
            if (args.length==1){
                if(args[0].equalsIgnoreCase("help")){
                    OccupationLanguage.sendAdminHelp(sender);
                    return true;
                }
            }
            if(args.length==2){
                if (args[0].equalsIgnoreCase("remove")){
                    OccupationManager.removeOccupation(sender,args[1]);
                    return true;
                }
                if(args[0].equalsIgnoreCase("occupation")){
                    OccupationLanguage.sendPlayerOccupation(sender,args[1]);
                    return true;
                }
            }
            if(args.length==3){
                if(args[0].equalsIgnoreCase("reset")){
                    OccupationManager.resetOccupation(sender,args[1],args[2]);
                    return true;
                }
            }
            OccupationLanguage.sendAdminHelp(sender);
            return true;
        }
        return false;
    }
}
